$(function(){
	app.controller('departmentController',departmentControllerFn);
});

function departmentControllerFn(){
	departmentSearch();
	$('#commit').click(function(){
		departmentSearch();
	})
	$('#depAdd').click(function(){
		window.location.href = "main/#/departmentAdd";
	});
}

function departmentSearch(){
	Main.ajaxPage("departmentHandle/departmentList",{"deptName":$("#deptName").val()},function(data){
		if(data != null && data != ""){
			var htmlStr;
			$.each(data,function (index,item) {
				htmlStr += "<tr style='text-align: center;'><td>"+item.deptId+"</td>" +
					"<td>"+item.deptName+"</td>" +
					"<td>"+item.deptRemark+"</td>" +
					"<td><a href='javascript:;' style='margin-right: 2px;'>修改</a><a href='javascript:;' style='margin-left: 2px;'>删除</a></td>" +
					"</tr>";
			});
			$("#ttbody").html(htmlStr);
		}
	})
}